 loadCSS(ELGG_MAPS_WEBPATH + 'css/elgg-maps.css');

/**
 * Agrega un <link> de css a <head> con la url
 * especificada.
 * @param {String} la URL del css a cargar
 */
function loadCSS(url)
{
	$("head").append($("<link rel='stylesheet' href='" + url + "' type='text/css' media='screen' />"));
}
/**
 * Serializa los campos de un formulario Serialize conviertiéndolos
 * en un objeto JSON
 * 
 * Inspired by jQuery.serializeArray()
 * @return {Object} un objeto JSON con los campos y valores del formularios
 */
$.fn.serializeObject = function()
{
    var o = {};
    var a = this.serializeArray();
    $.each(a, function() {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};


	/**
	 * Throw an exception if val is undefined
	 *
	 * @param {Mixed} val The variable you want to check
	 * @todo Might be more appropriate for debug mode only?
	 */
	function assertUndefined(val)
	{
		if (typeof val == 'undefined') {
			throw new TypeError("Param from " +
				arguments.caller + "is undefined");
		}
	}

	/**
	 * Throw an exception if val is a null object
	 *
	 * @param {Mixed} val The variable you want to check
	 * @todo Might be more appropriate for debug mode only?
	 */
	function assertNull(val)
	{
		assertTypeOf(val, 'object');
		if (val == null) {
			throw new TypeError("Param from " +
				arguments.caller + "is null");
		}
	}
	
	/**
	 * Throw an exception if the type doesn't match
	 *
	 * @param {Mixed} val The variable you want to check
	 * @param {String} The type to compare {val}'s type to.
	 * @todo Might be more appropriate for debug mode only?
	 */
	function assertTypeOf(val, type) {
		assertUndefined(val);
		if (typeof val !== type) {
			throw new TypeError("Expecting param of " +
				arguments.caller + "to be a(n) " + type + "." +
				"  Was actually a(n) " + typeof val + ".");
		}
	}

	/**
	 * Throw an exception if i is not an instance of c
	 *
	 * @param {Class} c The subclass to match to the object
	 * @param {Object} i The instance (object) to be checked
	 */
	function assertInstanceOf(c, i ) {
		assertNull(i);
		if (! (i instanceof c) ) {
			throw new TypeError("Expecting param of " +
				arguments.caller + "to be a(n) " + c.CLASS_NAME + "." +
				"  Was actually a(n) " + i.CLASS_NAME + ".");
		}
	};
